<?php
	class Fx_Data_Column_Renderer extends Fx_Data_View
	{
		// Mặc định kiểu render là text thông thường
		protected $_type = 'text';
		protected $_column = null;
		
		function __construct($_type = 'text', &$_column = null)
		{
			$this->_type = $_type;
			$this->_column = & $_column;
		}
		
		public function getColumn()
		{
			return $this->_column;	
		}
		
		public function setColumn(&$_column)
		{
			$this->_column = & $_column;
			return $this;
		}
		
		public function setType($_type = '')
		{
			if (is_string($_type) && !empty($_type)) 
			{
				$this->_type = $_type;	
			}
			return $this;
		}
		
		public function getType()
		{
			return (string)$this->_type;	
		}
		
		// Chuẩn hóa định dạng hiển thị
		public function renderOutputData()
		{
			$output = '';
			switch ($this->_type) 
			{
				case 'text':
					$output = $this->_column->getData();
				break;
				case 'textbox':
					$output = '<input type="text" id="txtId_'.$this->_column->getId().'" name="'.$this->_column->getId().'" value="'.$this->_column->getData().'" title="'.$this->_column->getHeading().'" style="width: '.$this->_width.'; height: '.$this->_height.'"/>';
				break;
				case 'password':
					$output = '<input type="password" id="pwdId_'.$this->_column->getId().'" name="'.$this->_column->getId().'" value="'.$this->_column->getData().'" title="'.$this->_column->getHeading().'" style="width: '.$this->_width.'; height: '.$this->_height.'"/>';
				break;
				case 'textarea':
					$output = '<textarea id="txaId_'.$this->_column->getId().'" name="'.$this->_column->getId().'" title="'.$this->_column->getHeading().'" style="width: '.$this->_width.'; height: '.$this->_height.'">'.$this->_column->getData().'"</textarea>';
				break;
				case 'checkbox':
					$output = '<input type="checkbox" id="chkId_'.$this->_column->getId().'" name="'.$this->_column->getId().'" value="'.$this->_column->getData().'" title="'.$this->_column->getHeading().'" style="width: '.$this->_width.'; height: '.$this->_height.'"/>';
				break;
				default:
					$output = $this->_column->getData();
				break;
			}
			return $output;
		}
	}
?>